package com.store.controller;

import com.store.common.Result;
import com.store.dto.response.DashboardResponse;
import com.store.service.DashboardService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/dashboard")
@RequiredArgsConstructor
public class DashboardController {

    private final DashboardService dashboardService;

    @GetMapping
    public Result<DashboardResponse> getDashboardData() {
        return Result.success(dashboardService.getDashboardData());
    }

    @GetMapping("/sales/trend")
    public Result<Map<String, Object>> getSalesTrend() {
        return Result.success(dashboardService.getSalesTrend());
    }

    @GetMapping("/sales/category")
    public Result<Map<String, Object>> getCategorySales() {
        return Result.success(dashboardService.getCategorySales());
    }

    @GetMapping("/sales/percentage")
    public Result<Map<String, Object>> getCategoryPercentage() {
        return Result.success(dashboardService.getCategoryPercentage());
    }
} 